import { formatDate } from "../../../utils";

export class DatepickerTraits {
    constructor(instance, trait_name) {
        var self = this;
        return {
            _data() {
                var ret = {};
                ret[trait_name] = self.private_data();
                self.private_methods(ret[trait_name]);
                return ret;
            },
        }
    }

    private_data() {
        return {
            value: new Date()
        }
    }

    private_methods(exports) {
        var instance = this;

        exports.getValue = function () {
            return exports.value;
        };

        exports.getFormatValue = function () {
            return formatDate(exports.getValue());
        };

        exports.onDateSelect = function (e) {
            var self = this;
            if (e.private_date) {
                if (exports.onChange) {
                    exports.onChange(formatDate(e.private_date))
                }
            }
        };
    }
}